package com.gzbsoft.sc.modules.sys.dao;
import com.gzbsoft.sc.modules.sys.entity.SysUser;
import org.springframework.data.ebean.annotation.Modifying;
import org.springframework.data.ebean.annotation.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
/**
 * 系统用户
 *
 * @author Mark sunlightcs@gmail.com
 */
@Repository
public interface SysUserDao extends BaseDao<SysUser, Long> {
    @Query(nativeQuery = true,value ="select id from sys_menu menu, ref_sys_user_role user_role, ref_sys_role_menu role_menu where user_role.sys_role_id = role_menu.role_id\n" +
            "and role_menu.menu_id = menu.id and user_role.sys_user_id =:userId")
    List<Long> queryAllMenuId(Long userId);

    @Modifying
    @Query(value="update jx_user u set u.username = :username where u.id = :id")
    int updatetUserInfo(@Param("username") String username, @Param("id") String id);

    @Modifying
    @Query(value = "insert into jx_user (username , password) values(:username ,:passowrd)")
    int addUserInfo(@Param("username") String username ,@Param("passowrd") String passowrd);


}
